package com.wl.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.wl.properties.GirlProperties;

/**
 * @author wl
 */
@RestController
@RequestMapping("/hello")
public class HelloController {

    @Autowired
    private GirlProperties girlProperties;
    
    @GetMapping(value = "/say")
    public String say(@RequestParam(value = "id", required = false, defaultValue = "0") Integer myId) {
        return "id: " + myId;
//        return girlProperties.getCupSize();
    }
    
    @SuppressWarnings("unused")
	@GetMapping("/testError")
    public ModelAndView testError(HttpServletRequest req) {
    	System.out.println(req.getSession().getAttribute("userId"));
    	
    	
    	ModelAndView mav = new ModelAndView();
    	StringBuffer url = req.getRequestURL();
    	mav.addObject("url", url.toString());
    	try {
			int i = 100/0;
		} catch (Exception e) {
			mav.addObject("e", e);
		}
    	mav.setViewName("error");
		return mav;
    }
}
